const crypto = require('crypto');
import { TOKEN_SECRET } from "../config";
//加密
export const encrypt = (data:any,secret:any=TOKEN_SECRET) => {
    var cipher = crypto.createCipher('aes192',secret);
    var enc = cipher.update(data,'utf8','hex');
    enc += cipher.final('hex');
    return enc;
}
//解密
export const decrypt = (data:any,secret:any=TOKEN_SECRET) => {
    var decipher = crypto.createDecipher('aes192',secret);
    var dec = decipher.update(data,'hex','utf8');
    dec += decipher.final('utf8');
    return dec;
}